#! /bin/bash
#用于将data下所有.in生成.out文件
c_file=`ls *.c`
exe_file=`ls *.exe`
if ${exe_file}
then
    gcc ${c_file} -c -o "${c_file:0:-2}.exe"
fi
exe_file=`ls *.exe`
# echo `cd data;ls *.in`
# read
for i in `cd data;ls *.in`
do
  echo "正在测试${i}";
  ./${exe_file:0:-5} < ./data/${i:0:1}.in > ./data/${i:0:1}test.out;
  test_ans=`cat ./data/${i:0:1}test.out`
  std_ans=`cat ./data/${i:0:1}.out`
  if [ "${test_ans}" = "${std_ans}" ] 
  then
    echo "${i}测试正确"
  else
    echo "${i}测试出错"
    echo "标准答案为 ${std_ans},你的文件输出的答案为${test_ans}"
  fi
done
# 清理对比文件
  rm ./data/*test.out    
read -p "按回车键退出" 

# echo "这是用于测试一下代码，请输入任意一个输入用于测试："
# ./${exe_file}
# ./Prob1.exe <./data/1.in > ./data/1.out